//    Copyright (C) Kherty.  All rights reserved.
using System;
using System.Diagnostics;
using System.Diagnostics.Contracts;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;

namespace OpenLS.Chart.UI
{
    partial class ChartLine3DResources
    {
        public ChartLine3DResources()
        {
            InitializeComponent();
        }
        static readonly ChartLine3DResources _singleton = new ChartLine3DResources();
        public static DataTemplate OutlineTemplate { get { return (DataTemplate)_singleton["OutlineTemplate"]; } }
        public static DataTemplate SideLine3DTemplate { get { return (DataTemplate)_singleton["SideLine3DTemplate"]; } }
        public static DataTemplate BackLine3DTemplate { get { return (DataTemplate)_singleton["BackLine3DTemplate"]; } }
        public static DataTemplate ChartLineInfoTemplate { get { return (DataTemplate) _singleton["ChartLineInfoTemplate"]; } }
        void OnGridLineLoaded(object sender, object args)
        {
            var e = (FrameworkElement)sender;
            var cm = new ContextMenu();
            cm.Items.Add(new MenuItem
            {
                Command = ApplicationCommands.Delete,
                CommandParameter = AxisElement.GetAxis(e)
            });

            e.ContextMenu = cm;
        }
        void OnGridLineMouseDown(object sender, MouseButtonEventArgs args)
        {
            var ee = (IInputElement)sender;
            ee.Focus();
            Contract.Assert(Keyboard.FocusedElement == ee);
            args.Handled = true;
        }

        private void OnDeleteGridLine(object sender, ExecutedRoutedEventArgs e)
        {
            var axis = (Axis)e.Parameter;
            if (axis.MinorGridLines != null)
                axis.MinorGridLines = null;
            else
                axis.MajorGridLines = null;
            e.Handled = true;
        }

    }
}
